object factorial {

  def fact(n: BigInt): BigInt =
    if (n < 1) 1 else n * fact(n - 1)

  /*
  def fact(n: Int): Int = {
    var total = 1
    List.range(1, n+1) foreach (total *= _)
    return total
  }
  */

  /*
  def fact(n: Int) =
    (1 /: List.range(2, n+1)) (_ * _)
  */

  
  def main(args: Array[String]) {
    //println(fact(args(0).toInt))
    import java.math.{BigInteger => JavaBigInt}

    // Annoying you have to drop into Java to go from String to BigInt.
    val num = new BigInt(new JavaBigInt(args(0)))

    println(fact(num))
  }

}
